package game.block.game;

import game.block.Constants;
import game.block.Locator;
import game.block.screen.BoardScreen;
import game.block.screen.LevelScreen;
import game.block.screen.MainMenuScreen;

import java.io.IOException;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.graphics.OrthographicCamera;

public class GameState implements Constants {

	private Game game;
	private Board gameBoard;
	private OrthographicCamera camera;
	private MainMenuScreen mainMenu;
	private BoardScreen boardScreen;
	private LevelScreen levelScreen;

	public GameState(Game game) {
		this.game = game;
		camera = new OrthographicCamera(SCREEN_WIDTH, SCREEN_HEIGHT);
		camera.position.set(SCREEN_WIDTH / 2, SCREEN_WIDTH / 2, 0);
		camera.zoom = 0.8f;
		camera.update();
		gameBoard = new Board(camera);

		boardScreen = new BoardScreen(gameBoard, camera, this);
		gameBoard.setScreen(boardScreen);
		mainMenu = new MainMenuScreen(this, game);
		levelScreen=new LevelScreen(this);
	}

	public void mainMenu() {
		game.setScreen(mainMenu);
	}

	public void play() {
		try {
			gameBoard.initNewBoard(Locator.getLevel());
		} catch (IOException e) {
			e.printStackTrace();
		}
		game.setScreen(boardScreen);
	}

	public void levelScreen() {
		game.setScreen(levelScreen);
	}

	public Game getGame() {
		return game;
	}

	public Board getGameBoard() {
		return gameBoard;
	}

	public OrthographicCamera getCamera() {
		return camera;
	}

	public MainMenuScreen getMainMenu() {
		return mainMenu;
	}

	public BoardScreen getBoardScreen() {
		return boardScreen;
	}

	public LevelScreen getLevelScreen() {
		return levelScreen;
	}

}
